# -*- coding:UTF-8 -*-#

'''
@author: qianwp
'''

import re

p1 = ('a-z|0-9|A-Z',)
email_pattern = re.compile('^[%s][%s|_|.]{0,100}@([%s]+.){1,4}[%s]+$' % (p1 * 4))
def validEmail(email):
    return len(email) > 4 and  email_pattern.match(email) is not None

nick_pattern = re.compile('^[\u4e00-\u9fa5|a-z|A-Z|0-9|_]+$')
def validNick(nick):
    _underLimit = 6
    _floorLimit = 20
    try:
        nick = nick.strip()
        if not re.match(u'^[\u4e00-\u9fa5|a-z|A-Z|0-9|_]+$',nick):
            return False
        _nick = nick.encode('gbk')
        _len = len(_nick)
        return _len >=_underLimit and _len <=_floorLimit
    except:
        return False

passwd_pattern = re.compile('^[a-z|A-Z|0-9]{6,20}$')
def validPasswd(passwd):
    return len(passwd) > 6 and passwd_pattern.match(passwd) is not None

def validRealname(realname):
    return validNick(realname)

def validContactnum(contactnum):
    return True

def validIdentnum(identnum):
    return True

def validAddress(address):
    return True

def validAlbumname(albumname):
    return True

digit_pattern = re.compile('^[0-9]{1,25}$')
def validDigit(someId):
    return digit_pattern.match(someId) is not None